<template>
  <div class="s-InteractionDemand">
    <el-form ref="ruleFormRef" :rules="rules" :model="ruleForm" label-width="80px" status-icon>
      <el-form-item label="需求标题" prop="name">
        <el-input v-model="ruleForm.name"></el-input>
      </el-form-item>
      <el-form-item label="需求类型" prop="DemandType">
        <el-radio-group v-model="ruleForm.DemandType">
          <el-radio :label="1">数据</el-radio>
          <el-radio :label="2">应用</el-radio>
          <el-radio :label="3">接口</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="功能描述" prop="synopsis">
        <el-input v-model="ruleForm.synopsis"></el-input>
      </el-form-item>
      <el-form-item label="数据领域" prop="dataField">
        <el-input v-model="ruleForm.dataField"></el-input>
      </el-form-item>
      <el-form-item label="用户类型" prop="UserType">
        <el-radio-group v-model="ruleForm.UserType">
          <el-radio :label="1">学生</el-radio>
          <el-radio :label="2">机关</el-radio>
          <el-radio :label="3">事业单位</el-radio>
          <el-radio :label="4">社会团体</el-radio>
          <el-radio :label="5">企业</el-radio>
          <el-radio :label="6">其他</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="数据格式" prop="DataType">
        <el-radio-group v-model="ruleForm.DataType">
          <el-radio :label="1">csv</el-radio>
          <el-radio :label="2">pdf</el-radio>
          <el-radio :label="3">xml</el-radio>
          <el-radio :label="4">xls</el-radio>
          <el-radio :label="5">其他</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="用      途" prop="PurposeType">
        <el-radio-group v-model="ruleForm.PurposeType">
          <el-radio :label="1">学习</el-radio>
          <el-radio :label="2">研究</el-radio>
          <el-radio :label="3">商业</el-radio>
          <el-radio :label="4">公益</el-radio>
          <el-radio :label="5">教育</el-radio>
          <el-radio :label="6">其他</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="职能部门" prop="departmentValue">
        <el-select v-model="ruleForm.departmentValue" placeholder="请选择">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <p class="submit">
          <el-button @click="submit(ruleFormRef)">提交</el-button>
        </p>
      </el-form-item>
    </el-form>
  </div>
</template>
<script setup>
import { ref, reactive } from "vue";
const formSize = ref("default");
const ruleFormRef = ref();
const options = [
  {
    value: "市教育局",
    label: "市教育局",
  },
  {
    value: "市科技局",
    label: "市科技局",
  },
  {
    value: "市财政局",
    label: "市财政局",
  },
  {
    value: "市司法局",
    label: "市司法局",
  },
  {
    value: "市民政局",
    label: "市民政局",
  },
];
const ruleForm = reactive({
  // title: "",
});
const rules = reactive({
  name: [
    { required: true, message: "请输入需求标题", trigger: "blur" },
    { min: 3, max: 10, message: "长度在 3 到 10 个字符", trigger: "blur" },
  ],
  DemandType: [{ required: true, message: "请选择需求类型", trigger: "change" }],
  synopsis: [
    { required: true, message: "请输入功能描述", trigger: "blur" },
    { min: 3, max: 10, message: "长度在 3 到 10 个字符", trigger: "blur" },
  ],
  dataField: [
    { required: true, message: "请输入数据领域", trigger: "blur" },
    { min: 3, max: 10, message: "长度在 3 到 10 个字符", trigger: "blur" },
  ],
  UserType: [{ required: true, message: "请选择用户类型", trigger: "change" }],
  DataType: [{ required: true, message: "请选择用户类型", trigger: "change" }],
  PurposeType: [{ required: true, message: "请选择用 途", trigger: "change" }],
  departmentValue: [{ required: true, message: "请选择职能部门", trigger: "change" }],
});

const submit = async formEl => {
  if (!formEl) return;
  await formEl.validate(valid => {
    if (valid) {
      console.log(ruleForm);
    } else {
      console.log("error submit!!");
      return false;
    }
  });
};
</script>
